<?php defined('_JEXEC') or die('Restricted access'); ?>

<?php JHTML::_('behavior.tooltip'); ?>

<?php
	// Set toolbar items for the page
	$edit		= JRequest::getVar('edit',true);
	$text = !$edit ? JText::_( 'NEW' ) : JText::_( 'EDIT' );
	JToolBarHelper::title(   JText::_( 'ROKQUICKCART_CARTITEM' ).': <small><small>[ ' . $text.' ]</small></small>','rokquickcart.png' );
	JToolBarHelper::save();
	if (!$edit)  {
		JToolBarHelper::cancel();
	} else {
		// for existing items the button is renamed `close`
		JToolBarHelper::cancel( 'cancel', 'Close' );
	}
	JToolBarHelper::help( 'screen.rokquickcart.edit', true );
?>

<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}

		// do field validation
		if (form.name.value == ""){
			alert( "<?php echo JText::_( 'ROKQUICKCART.ERR.NAME_MISSING', true ); ?>" );
		} else {
		    submitform( pressbutton );
		}
	}
</script>
<style type="text/css">
	table.paramlist td.paramlist_key {
		width: 92px;
		text-align: left;
		height: 30px;
	}
</style>

<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col width-60">
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'DETAILS' ); ?></legend>

		<table class="admintable">
		<tr>
			<td width="100" align="right" class="key">
				<label for="name" class="hasTip" title="<?php echo JText::_( 'NAME' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.NAME');?>">
					<?php echo JText::_( 'Name' ); ?>:
				</label>
			</td>
			<td>
				<input class="inputbox" type="text" name="name" id="name" size="40" maxlength="255" value="<?php echo $this->cartitem->name;?>" />
				
			</td>
		</tr>
		<tr>
		<td width="100" align="right" class="key">
				<label for="name" class="hasTip" title="<?php echo JText::_( 'ROKQUICKCART.PRICE' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.PRICE');?>">
					<?php echo JText::_( 'ROKQUICKCART.PRICE' ); ?>:
				</label>
			</td>
			<td>
				<input class="inputbox" type="text" name="price" id="price" size="10" maxlength="10" value="<?php echo $this->cartitem->price;?>" />
				
			</td>
		</tr>
		<td width="100" align="right" class="key">
				<label for="name" class="hasTip" title="<?php echo JText::_( 'ROKQUICKCART.SHIPPING_COST' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.SHIPPING_COST');?>">
					<?php echo JText::_( 'ROKQUICKCART.SHIPPING_COST' ); ?>:
				</label>
			</td>
			<td>
				<input class="inputbox" type="text" name="shipping" id="shipping" size="10" maxlength="10" value="<?php echo $this->cartitem->shipping;?>" />
				
			</td>
		</tr
		<tr>
			<td valign="top" align="right" class="key">
				<label for="published" class="hasTip" title="<?php echo JText::_( 'Published' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.PUBLISHED');?>">
					<?php echo JText::_( 'Published' ); ?>:
				</label>
			</td>
			<td>
				<?php echo $this->lists['published']; ?>
			</td>
		</tr>
		<tr>
			<td valign="top" align="right" class="key">
				<label for="ordering" class="hasTip" title="<?php echo JText::_( 'ORDERING' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.ORDERING');?>">
					<?php echo JText::_( 'ORDERING' ); ?>:
				</label>
			</td>
			<td>
				<?php echo $this->lists['ordering']; ?>
			</td>
		</tr>
		<tr>
			<td class="key">
				<label for="image" class="hasTip" title="<?php echo JText::_( 'ROKQUICKCART.LABEL.CART_ITEM_IMAGE' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.CART_ITEM_IMAGE');?>">
					<?php echo JText::_( 'ROKQUICKCART.LABEL.CART_ITEM_IMAGE' ); ?>:
				</label>
			</td>
			<td>
				<input class="inputbox" type="text" name="image" id="image" readonly="true" size="50" maxlength="255" value="<?php echo $this->cartitem->image;?>" onchange="javascript:
					if (document.forms.adminForm.image.value!='') {
						document.image_img.src='../'+document.forms.adminForm.image.value;
					} 
					else {
						document.image_img.src='../images/blank.png';
					}"/><a class="modal-button" rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php?option=com_rokquickcart&amp;view=images&amp;tmpl=component&amp;e_name=image"> <?php echo JText::_('ROKQUICKCART_PICK_IMAGE');?></a> 
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>
			<script language="javascript" type="text/javascript">
			if (document.forms.adminForm.image.value!=''){
				jsimg='../' + document.forms.adminForm.image.value;
			} else {
				jsimg='../images/M_images/blank.png';
			}
			document.write('<img src=' + jsimg + ' width="<?php echo $this->image_width;?>" name="image_img" border="2" alt="<?php echo JText::_( 'Preview', true ); ?>"');
			</script>
			</td>
		</tr>
	    </table>
	</fieldset>
	<fieldset class="adminform">
		<legend for="description" class="hasTip" title="<?php echo JText::_( 'Description' ); ?>::<?php echo JText::_('ROKQUICKCART.TIP.DESCRIPTION'); ?>"><?php echo JText::_( 'Description' ); ?></legend>
		<table class="adminform">
		<tr>
			<td>
				<?php
				// parameters : areaname, content, width, height, cols, rows
				echo $this->editor->display( 'description',  $this->cartitem->description , '100%', '350', '75', '20', false) ;
				?>
			</td>
		</tr>
		</table>
	</fieldset>
</div>
<div class="col width-40">
		<?php
			echo $this->pane->startPane("params-pane");
			$title = JText::_( 'ROKQUICKCART.LABEL.CUSTOM_FIELDS' );
			echo $this->pane->startPanel( $title, "detail-page" );
			echo $this->params->render('params');
			echo $this->pane->endPanel();			
			echo $this->pane->endPane();
		?>
</div>
<div class="clr"></div>

	<input type="hidden" name="option" value="com_rokquickcart" />
	<input type="hidden" name="cid[]" value="<?php echo $this->cartitem->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>